package console;

import java.util.Observable;

/**
 *
 * @author Michael Hanns
 *
 */
public class IOBufferImp extends Observable implements IOBuffer {

    String previousText;
    String terminalText;

    public IOBufferImp() {
        previousText = "";
        terminalText = "";
    }

    @Override
    public String getText() {
        String temp = terminalText;
        previousText = previousText + ("\n"+terminalText);
        terminalText = "";
        return temp;
    }

    @Override
    public synchronized void writeTo(String input) {
        terminalText = input;
        this.setChanged();
        this.notifyObservers();
    }

}
